package com.sky.controller.user;

import com.sky.dto.OrdersPaymentDTO;
import com.sky.dto.OrdersSubmitDTO;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderSubmitVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/order")
@Api(tags = "C端-订单接口")
public class OrderUserController {
    @Autowired
    OrderService orderService;

    /**
     * 提交订单
     * @param ordersSubmitDTO
     * @return
     */
    @PostMapping("/submit")
    @ApiOperation("提交订单")
    public Result submit(@RequestBody OrdersSubmitDTO ordersSubmitDTO){
        OrderSubmitVO ordersSubmitVO = orderService.submit(ordersSubmitDTO);
        return Result.success(ordersSubmitVO);
    }

    @PutMapping("/payment")
    @ApiOperation("订单支付")
    public Result payment(@RequestBody OrdersPaymentDTO ordersPaymentDTO){
        System.out.println("要支付的订单号是:"+ordersPaymentDTO.getOrderNumber());
       //OrderPaymentVO orderPaymentVO =  orderService.payment(ordersPaymentDTO);
        //todo 这里要和微信交互
        //1.根据订单号去微信报备
        //2.根据微信返回的内容封装处理(复杂)
        return Result.success(null);
    }

}
